<script setup>
// computed
//1. 语法
// - 函数式computed
// - 对象式conputed

//2. 与vue2computed对比
// - vue2 通过computed:{ 属性名:函数/对象 }
// - vue3 通过  函数名 = computed(函数/对象)

import { computed, ref } from 'vue';

const age = ref('')
// 函数式computed
const preAge = computed(() => age.value - 1)
// 对象式conputed
const nextAge = computed({
  get() {
    return +preAge.value + 2
  }
})



</script>
<template>
  <div>
    <span>去年的岁数:{{ preAge }} </span>
    <br />

    <span>现在岁数:</span>
    <input type="text" v-model="age">

    <br />
    <span>明年的岁数:{{ nextAge }} </span>

  </div>
</template>

